package com.demo.widget.guhong;

import com.demo.widget.BaseAbility;
import com.demo.widget.ResourceTable;

import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

/**
 * 郭鸿控件主页
 */
public class MainAbility extends BaseAbility implements Component.ClickedListener {

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main_guhong);
        findComponentById(ResourceTable.Id_tv_bounce_ball).setClickedListener(this);
        findComponentById(ResourceTable.Id_tv_ripple).setClickedListener(this);
        findComponentById(ResourceTable.Id_tv_line_path).setClickedListener(this);
    }

    @Override
    public void onClick(Component component) {
        Intent intent = new Intent();
        switch (component.getId()) {
            case ResourceTable.Id_tv_bounce_ball:
                intent.setOperation(new Intent.OperationBuilder().withAbilityName(BounceBallAbility.class).withBundleName(getBundleName()).build());
                break;
            case ResourceTable.Id_tv_ripple:
                intent.setOperation(new Intent.OperationBuilder().withAbilityName(MeiRippleAbility.class).withBundleName(getBundleName()).build());
                break;
            case ResourceTable.Id_tv_line_path:
                intent.setOperation(new Intent.OperationBuilder().withAbilityName(MeiLinePathAbility.class).withBundleName(getBundleName()).build());
                break;
        }
        startAbility(intent);
    }
}
